﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace crm_web.Controls
{
	public static class SitemapControl
	{
		private static SitemapPage Root { get; set; }

		public static string BulletedList
		{
			get
			{
				return Root.ToBulletedList();
			}
		}


		public static void BuildSitemap()
		{
			Pages.Init();

			Root = Pages.Root;
			Root.AddChild(Pages.Home);
			Root.AddChild(Pages.Dashboard);

			Root.AddChild(Pages.CSR); // *************************** CSR

			Root.AddChild(Pages.SA); // *************************** SA
			Pages.SA.AddChild(Pages.MakeASale);

			Root.AddChild(Pages.Manager); // *************************** Manager
			Pages.Manager.AddChild(Pages.SalesReport);

			Root.AddChild(Pages.Admin); // *************************** Admin
			Pages.Admin.AddChild(Pages.SalesReport);
			Pages.Admin.AddChild(Pages.ManageClients);
			Pages.Admin.AddChild(Pages.ManageFollowUps);
			Pages.Admin.AddChild(Pages.ManageProducts);
			Pages.Admin.AddChild(Pages.ManageSales);
			Pages.Admin.AddChild(Pages.ManageSaleItems);
			Pages.Admin.AddChild(Pages.ManageUsers);
		}

		private static class Pages
		{
			/*Root*/
			public static SitemapPage Root { get; set; }

			public static SitemapPage Home { get; set; }
			public static SitemapPage Dashboard { get; set; }

			/* Buckets */
			public static SitemapPage Admin { get; set; }
			public static SitemapPage CSR { get; set; }
			public static SitemapPage Manager { get; set; }
			public static SitemapPage SA { get; set; }

			/* Tasks */
			public static SitemapPage MakeASale { get; set; }

			/* Reports */
			public static SitemapPage SalesReport { get; set; }

			/* DataPages */
			public static SitemapPage ManageClients { get; set; }
			public static SitemapPage ManageFollowUps { get; set; }
			public static SitemapPage ManageProducts { get; set; }
			public static SitemapPage ManageSales { get; set; }
			public static SitemapPage ManageUsers { get; set; }
			public static SitemapPage ManageSaleItems { get; set; }

			public static void Init()
			{
				Root = new SitemapPage
				{
					URL = "/",
					Roles = new List<string> { "*" },
					DisplayText = "Root",
					DescriptionText = "Root"
				};

				Home = new SitemapPage
						{
							URL = "/Default.aspx",
							Roles = new List<string> { "*" },
							DisplayText = "Home",
							DescriptionText = "Home page"
						};
				Dashboard = new SitemapPage
						{
							URL = "/Dashboard.aspx",
							Roles = new List<string> { "?" },
							DisplayText = "Dashboard",
							DescriptionText = "Dashboard"
						};
				/* Buckets */
				Admin = new SitemapPage
						{
							URL = "/Admin/",
							Roles = new List<string> { "Admin" },
							DisplayText = "Admin",
							DescriptionText = "Admin Pages"
						};
				CSR = new SitemapPage
						{
							URL = "/CSR/",
							Roles = new List<string> { "CSR" },
							DisplayText = "Customer Service",
							DescriptionText = "Customer Service Rep Pages"
						};
				Manager = new SitemapPage
						{
							URL = "/Manager/",
							Roles = new List<string> { "Manager" },
							DisplayText = "Managers",
							DescriptionText = "Manager Pages"
						};
				SA = new SitemapPage
						{
							URL = "/SA/",
							Roles = new List<string> { "SA" },
							DisplayText = "Sales",
							DescriptionText = "Sales Agent Pages"
						};

				/* Tasks */
				MakeASale = new SitemapPage
				{
					URL = "/TaskPages/MakeASale.aspx",
					DisplayText = "Make A Sale",
					DescriptionText = "Make A Sale"
				};

				/* Reports */
				SalesReport = new SitemapPage
						{
							URL = "/ReportPages/SalesReports.aspx",
							DisplayText = "Sales Reports",
							DescriptionText = "Sales Reports"
						};

				/* DataPages */
				ManageClients = new SitemapPage
						{
							URL = "/DataPages/Clients.aspx",
							DisplayText = "List Clients",
							DescriptionText = "Manage Client Information"
						};
				ManageFollowUps = new SitemapPage
						{
							URL = "/DataPages/FollowUp.aspx",
							DisplayText = "List Follow-Ups",
							DescriptionText = "Manage Follow-Up Information"
						};
				ManageProducts = new SitemapPage
						{
							URL = "/DataPages/Product.aspx",
							DisplayText = "List Products",
							DescriptionText = "Manage Product Information"
						};
				ManageSales = new SitemapPage
						{
							URL = "/DataPages/Sale.aspx",
							DisplayText = "List Sales",
							DescriptionText = "Manage Sale Information"
						};
				ManageSaleItems = new SitemapPage
						{
							URL = "/DataPages/SaleItem.aspx",
							DisplayText = "List SaleItems",
							DescriptionText = "Manage SaleItem Information"
						};
				ManageUsers = new SitemapPage
						{
							URL = "/DataPages/Users.aspx",
							DisplayText = "List Users",
							DescriptionText = "Manage User Information"
						};

			}


		}
	}
}